<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/axios-0.18.0.js"></script>
    <script src="js/vue-v2.6.11.js"></script>
</head>
<body>
<div id="app">
    <button @click="testGet">get请求</button>
    <button @click="testPost">post请求</button>
    <button @click="testPut">put请求</button>
    <button @click="testDelete">delete请求</button>
</div>
</body>
<script type="text/javascript">
    new Vue({
        el:"#app",
        data:{

        },
        methods:{
            testGet(){
                axios.get("/user/1").then((res)=>{
                    console.log(res);
                }).catch((err)=>{
                    console.log(err);
                });
            },
            testPost(){
                var param = {
                    id:1,
                    username:"张三",
                    age:19
                };
                axios.post("/user/",param).then((res)=>{
                    console.log(res);
                }).catch((err)=>{
                    console.log(err);
                });
            },
            testPut(){
                var param = {
                    id:2,
                    username: "李四",
                    age: 20
                };
                axios.put("/user/",param).then((res)=>{
                    console.log(res);
                }).catch((err)=>{
                    console.log(err);
                });
            },
            testDelete(){
                axios.delete("/user/3").then((res)=>{
                    console.log(res);
                }).catch((err)=>{
                    console.log(err);
                });
            }
        }
    })
</script>
</html>